<?php
$this->headTitle($this->translator('enterprise_search_page_title'));
?>
<style>
    .col_50l{
        float:left;
        width:48%;
    }
    .col_50r{
        float:right;
        width:48%;
    }
    .subrow{
        padding-bottom:10px;
        display:table;
        width:100%;
    }
    .col_70l{
        float:left;
        width:69.2%;
    }
    .col_30r{
        float:right;
        width:30%;
    }
    .col_30l{
        float:left;
        width:29%;
    }
    .col_70r{
        float:right;
        width:70%;
    }
    .webwidget_vertical_menu li{
        margin-left:0px;
    }
    .caption_box{
        margin-bottom:5px; background:#EFEDED none repeat;
    }
    .caption_box span{
        padding:8px;
        text-transform:uppercase;
    }
    .box_33l{
        float:left;
        width:33.3%;
        background:#EFEDED none repeat;
    }
    .subbox_33l{
        background:#FFFFFF;
        margin:5px 0px 10px 5px;
        padding:5px
    }
</style>
<?php
    $skin_url = $this->APP_STATIC_SERVER . '/skins/'. $this->APP_TEMPLATE . '/'. $this->APP_SKIN;
?>
<div class="grid_12 pb10">
    <!--Search form-->
    <form action="<?php echo $this->url(array(), 'bizprofile_enterprise_search')?>" method="POST" id="searchForm">
        <div style="background:#EFEDED none repeat;">
            <div style="padding:10px;">
                <input value="<?php echo isset($this->exp['keyword'])?$this->exp['keyword']:null;?>" name="keyword" type="text" style="width:400px; height:15px;padding:3px 0" />
                <input type="submit" value="<?php echo $this->translator('enterprise_btn_search');?>" style="height:24px; padding:0 0 4px" />
                <a href="<?php echo $this->url(array(), 'bizprofile_enterprise_search_advanced')?>"><?php echo $this->translator('enterprise_search_advanced');?></a>
            </div>
        </div>
    </form>
    <!--End search form-->
</div>
<div class="grid_12">
    <div class="col_70l">
        <div class="subcolumns ">
            <?php if($this->key):?>
                <div class="caption_box icon_title">
                    <span><?php echo $this->translator('enterprise_search_result');?></span>
                </div>
                <div>&nbsp;</div>
                <!--Tab-->
                <div class="subcolumns tabs pb10">
                    <ul class="tabNavigation">
                        <li><a href="#tab1" id="basic"><?php echo $this->translator('enterprise_search_enterprise')?>(<?php echo $this->numBasic;?>)</a></li>
                        <li><a href="#tab2" id="info"><?php echo $this->translator('enterprise_search_info')?>(<?php echo $this->numInfo;?>)</a></li>
                        <li><a href="#tab3" id="blog"><?php echo $this->translator('enterprise_search_blog')?>(<?php echo $this->numBlog;?>)</a></li>
                    </ul>

                    <div id="tab1">
                        <div id="basicOutput" class="col_70l" style="display:table; width:100%;">tab1</div>
                    </div>
                    <div id="tab2" style="display: block;">
                        <div id="infoOutput" class="col_70l" style="display:table; width:100%;">tab2</div>
                    </div>
                    <div id="tab3" style="display: block;">
                        <div id="blogOutput" class="col_70l" style="display:table; width:100%;">tab3</div>
                    </div>
                </div>
                <!--end tab-->
            <?php else:?>
                <div style="text-align:center"><?php echo $this->translator('search_not_key');?></div>
            <?php endif;?>
        </div>
    </div>
    <div class="col_30r">
        <!--Most viewed box-->
        <?php echo $this->widget('bizprofile','mostviewed',array()); ?>

        <!--Most buy box-->
        <?php echo $this->widget('bizprofile','mostbuy',array()); ?>
    </div>
</div>
<script type="text/javascript" charset="utf-8">
    $(function () {
        var tabContainers = $('div.tabs > div');
        tabContainers.hide().filter(':first').show();

        $('div.tabs ul.tabNavigation a').click(function () {
                tabContainers.hide();
                tabContainers.filter(this.hash).show();
                $('div.tabs ul.tabNavigation a').removeClass('selected');
                $(this).addClass('selected');
                return false;
        }).filter(':first').click();
    });
</script>
<script type="text/javascript">
$(document).ready(function() {

    $('div.tabs ul.tabNavigation a').click(function () {
        key = $(this).attr('id');
        val = $(this).attr('val');
        if(key == 'basic' && val != 'is_loaded'){
            basicLoad();
        }
        else if(key == 'info' && val != 'is_loaded'){
            infoLoad();
        }
        else if(key == 'blog' && val != 'is_loaded'){
            blogLoad();
        }
    });

    /**Auto load ajax*/
    <?php if($this->key):?>
    basicLoad();
    <?php endif;?>
});

function basicLoad(){
    var keyword = '<?php echo isset($this->exp['keyword'])?$this->exp['keyword']:null;?>';

    $("#basicOutput").html('').addClass('t_a_ui_helper_loading');
    jQuery.ajaxq('basic', {
        type: 'POST',
        url: "<?php echo $this->url(array(), 'bizprofile_enterprise_basic_ajax'); ?>",
        data: { keyword:keyword },
        success: function(html) {
            $("#basicOutput").html('').removeClass('t_a_ui_helper_loading');
            $('#basicOutput').html(html);

            /**
            * Set is loaded
            */
            $('#basic').attr('val', 'is_loaded');
        }
    });
}

function infoLoad(){
    var keyword = '<?php echo isset($this->exp['keyword'])?$this->exp['keyword']:null;?>';

    $("#infoOutput").html('').addClass('t_a_ui_helper_loading');
    jQuery.ajaxq('info', {
        type: 'POST',
        url: "<?php echo $this->url(array(), 'bizprofile_enterprise_info_ajax'); ?>",
        data: { keyword:keyword },
        success: function(html) {
            $("#infoOutput").html('').removeClass('t_a_ui_helper_loading');
            $('#infoOutput').html(html);

            /**
            * Set is loaded
            */
            $('#info').attr('val', 'is_loaded');
        }
    });
}

function blogLoad(){
    var keyword = '<?php echo isset($this->exp['keyword'])?$this->exp['keyword']:null;?>';

    $("#blogOutput").html('').addClass('t_a_ui_helper_loading');
    jQuery.ajaxq('blog', {
        type: 'POST',
        url: "<?php echo $this->url(array(), 'bizprofile_enterprise_blog_ajax'); ?>",
        data: { keyword:keyword },
        success: function(html) {
            $("#blogOutput").html('').removeClass('t_a_ui_helper_loading');
            $('#blogOutput').html(html);

            /**
            * Set is loaded
            */
            $('#blog').attr('val', 'is_loaded');
        }
    });
}
</script>